<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.carebuddy.petcare.biz.*"%>
<%@ page import="com.carebuddy.petcare.controller.*"%>
<%
	Carebuddy carebuddy = new Carebuddy();
	PetcareController petcareController = carebuddy.getPetcareController();
	UserController userController = carebuddy.getUserController();
	userController.getCookie(request, response);
	petcareController.listPetcare_details(request, request.getParameter("apply_id"));
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<title>위탁 신청서</title>
</head>
<script src="./jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="./calendar.js"></script>
<script language="javascript">
	function insert_chk(){
		var frm = document.apply_frm;
		 if(frm.date.value=="" || frm.date.value==null){
			 alert("위탁희망일을 입력하지 않았습니다.");
			 frm.date.focus();}
		 else if(frm.tdate.value=="" || frm.tdate.value==null){
			 alert("상태확인일을 입력하지 않았습니다.");
			 frm.tdate.focus();}
		 else frm.submit();
	}
	
	function categSelect(){//select태그 2단으로 사용
		var categ = document.apply_frm.category;
		var kind = document.apply_frm.kind;
		
		while(kind.length != 0){
			kind.options.remove(0);
		}
		
		if(categ.value=='강아지'){
			kind.options.add(new Option("-강아지 종을 선택하세요-", "0"));
			kind.options.add(new Option("강아지종1", "강아지종1"));
			kind.options.add(new Option("강아지종3", "강아지종3"));
			kind.options.add(new Option("강아지종2", "강아지종2"));
		}else if(categ.value=='고양이'){
			kind.options.add(new Option("-고양이 종을 선택하세요-", "0"));
			kind.options.add(new Option("고양이종1", "고양이종1"));
			kind.options.add(new Option("고양이종3", "고양이종3"));
			kind.options.add(new Option("고양이종2", "고양이종2"));
		}
	}
	
	function mod(k,kt){//라디오버튼 자동체크
		for(var i = 0; i<k.length; i++){
			if(k[i].value==kt[0].value)
				k[i].checked=true;
		}
	}
	
	$(document).ready(function() {//이전 입력사항 로드
		mod(document.getElementsByName("mf"), document.getElementsByName("m_mf"));
		mod(document.getElementsByName("jsh"), document.getElementsByName("m_jsh"));
		mod(document.getElementsByName("fur"), document.getElementsByName("m_fur"));
		mod(document.getElementsByName("alert"), document.getElementsByName("m_alert"));
		document.getElementsByName("category")[0].value = document.getElementsByName("m_category")[0].value;
		categSelect();//분류를 먼저 선택해야 종을 고를 수 있게 되어서.. 함수 호출
		document.getElementsByName("kind")[0].value = document.getElementsByName("m_kind")[0].value;
	});

</script>
<body class="bodystyle" >
	<form action=wt_mod_proc.jsp name="apply_frm" method="post">
	<input type="hidden" name="user_id" value="${user_id}">
	<input type="hidden" name="apply_id" value="${details.getApply_id()}">
	<table width="650" align="center">
	  <tr>
	    <td><img src="../../images/apply.jpg"></td>
      </tr>
	  <tr>
	    <td>
	    	<table align="left">
		      <tr>
		        <td class="bodytitle">위탁희망일 :</td>
		        <td><input type="text" id="date" name="date" onclick="fnPopUpCalendar(date,date,'yyyy/mm/dd')" class='text_box1' size="10" value="${details.getDate()}"></td>
		        <td class="bodytitle">상태확인일 :</td>
		        <td><input type="text" id="tdate" name="tdate" onclick="fnPopUpCalendar(tdate,tdate,'yyyy/mm/dd')" class='text_box1' size="10" value="${details.getTdate()}"></td>
	          </tr>
	        </table>
	    </td>
	   </tr>
	   <tr>
	   	<td>
	   		<table align="left">
		    	<tr>
			      <td class="bigstyle">반려동물 정보</td>
		        </tr>
			    <tr>
			      <td class="bodytitle">분류 :<input type="hidden" name="m_category" value="${details.getCategory()}"></td>
			      <td><select name="category" onchange="categSelect();">
			      	<option value="none">분류를 선택하세요</option>
			      	<option value="강아지">강아지</option>
			      	<option value="고양이">고양이</option>
			      	</select>
			      </td>
			      <td class="bodytitle">종 :<input type="hidden" name="m_kind" value="${details.getKind()}"></td>
			      <td><select name="kind">
			      	<option value="none">분류를 선택하세요</option>
			      	</select></td>
		        </tr>
		        <tr>
			      <td class="bodytitle">이름 :</td>
			      <td><input type="text" size="10" name="pname" value="${details.getPname()}"></td>
			      <td class="bodytitle">몸무게 :</td>
			      <td><input type="text" size="10" name="weight" value="${details.getWeight()}"></td>
		        </tr>
		        <tr>
			      <td class="bodytitle">나이 :</td>
			      <td><input type="text" size="10" name="age" value="${details.getAge()}"></td>
			      <td class="bodytitle">성별 :<input type="hidden" name="m_mf" value="${details.getMf()}"></td>
			      <td><input type="radio" name="mf" value="남">남
			          <input type="radio" name="mf" value="여">여</td>
		        </tr>
		        <tr>
			      <td class="bodytitle">중성화여부 :<input type="hidden" name="m_jsh" value="${details.getJsh()}"></td>
			      <td><input type="radio" name="jsh" value="O">O
			          <input type="radio" name="jsh" value="X">X</td>
			      <td class="bodytitle">털 상태 :<input type="hidden" name="m_fur" value="${details.getFur()}"></td>
			      <td><input type="radio" name="fur" value="단모">단모
			          <input type="radio" name="fur" value="중모">중모
			          <input type="radio" name="fur" value="장모">장모</td>
		        </tr>
         	 </table>
	   	</td>
	   </tr>
       <tr>
       	<td>
       		<table align="left">
	          	<tr>
		       	  <td class="bigstyle">병력사항</td>
	          	</tr>
		      	<tr>
			      <td class="bodytitle">예방접종 :</td>
			      <td><input type="text" size="10" name="ybjj" value="${details.getYbjj()}"></td>
		        </tr>
		        <tr>
			      <td class="bodytitle">치료경력 :</td>
			      <td><input type="text" size="10" name="crgr" value="${details.getCrgr()}"></td>
		        </tr>
		        <tr>
			      <td class="bodytitle">복용중인 약 :</td>
			      <td><input type="text" size="10" name="medicine" value="${details.getMedicine()}"></td>
		        </tr>
		        <tr>
		       	  <td class="bodytitle">특이사항</td>
	          	</tr>
	          	<tr>
			      <td class="bodytitle">낯선사람에 대한 경계 :<input type="hidden" name="m_alert" value="${details.getAlert()}"></td>
			      <td><input type="radio" name="alert" value="O">O
			          <input type="radio" name="alert" value="X">X</td>
		        </tr>
	        </table>
       	</td>
       </tr>  	
	  <tr>
	  	<td colspan="2" align="center"><input type="button" class="buttonstyle" value="위탁신청 수정하기" onclick="insert_chk();"/></td>
	  </tr>
	  </table>
	</form>
</body>
</html>